<!-- 原料类别  部门分析 -->
<template>
  <div class="clas_All">
    <el-table :data="tableData">
      <el-table-column align="center" prop="pname" label="部门名称">
      </el-table-column>
      <el-table-column align="center" label="实际成本/元">
        <el-table-column align="center" prop="realCostCurrent" label="本期">
        </el-table-column>
        <el-table-column align="center" prop="realCostUpper" label="上期">
        </el-table-column>
      </el-table-column>
      <el-table-column align="center" label="标准成本/元">
        <el-table-column align="center" prop="standardCostCurrent" label="本期">
        </el-table-column>
        <el-table-column align="center" prop="standardCostUpper" label="上期">
        </el-table-column>
      </el-table-column>
      <el-table-column align="center" label="损益金额/元">
        <el-table-column align="center" prop="prolossCostCurrent" label="本期">
        </el-table-column>
        <el-table-column align="center" prop="prolossCostUpper" label="上期">
        </el-table-column>
      </el-table-column>
      <el-table-column align="center" label="损益率">
        <el-table-column align="center" prop="prolossRateCurrent" label="本期">
        </el-table-column>
        <el-table-column align="center" prop="prolossRateUpper" label="上期">
        </el-table-column>
      </el-table-column>
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <div>
            <el-button size="mini" type="text" @click="GodeptW(scope.row)"
              >该部门该类物料损益分析</el-button
            >
          </div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { topcateDept } from "@/api/system/cost";
import { getPanDianCode, FindShopBom } from "@/api/system/stock";
export default {
  props: {
    dataOne: {
      type: Array,
    },
  },
  data() {
    return {
      queryParams: {
        shopCode: "",
        pandianCode: "",
      },
      tableData: [],
      examineOption: [],

      deptOptions: [],
      DropDownList: [],
      NewDropDownList: [],
      tableData: [],
      byMonth: {},
      mouday: true,
      mount: true,
      defaultProps: {
        children: "children",
        label: "label",
      },
    };
  },
  created() {
    this.queryParams.shopCode = this.$route.query.shopCode;
    this.queryParams.pandianCode = this.$route.query.pandianCode;
    this.queryParams.deptcode = this.$route.query.stapType;
    this.getList();
    this.getFind();
  },
  methods: {
    handleQuery() {},
    getList() {
      topcateDept(this.queryParams).then((res) => {
        if (res.code == 200) {
          this.tableData = res.data;
        }
      });
    },
    GodeptW(v) {
      this.$router.push({
        path: "/ProfitDepartment",
        query: {
          pandianCode: this.queryParams.pandianCode,
          shopCode: this.queryParams.shopCode,
          deptCode: v.deptCode,
          stapTypeCode: this.queryParams.stapTypeCode,
        },
      });
      // sectoralAnalysis/ProfitDepartment 该部门该类损益分析
    },
    getFind() {
      FindShopBom().then((res) => {
        if (res.code == 200) {
          this.deptOptions = res.data;
        }
      });
    },
    createdTimeChange(v) {
      let data = new Date(v);
      let y = data.getFullYear();
      let m = data.getMonth() + 1;
      this.byMonth.pandianData = y + String(m).padStart(2, "0");

      getPanDianCode(this.byMonth).then((res) => {
        if (res.code == 200) {
          this.DropDownList = res.data;
          this.NewDropDownList = [];
          this.DropDownList.forEach((element) => {
            let label =
              new Date(element.startTime).getDate() +
              "号-" +
              new Date(element.endTime).getDate() +
              "号";
            this.NewDropDownList.push({
              value: element.pandianCode,
              label: label,
            });
          });
          if (res.data != []) {
            this.mount = false;
          }
        }
      });
    },
    deptChange(v) {
      if (v) {
        this.mouday = false;
      } else {
        this.mouday = true;
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.clas_All {
  margin: 20px;
}
</style>
